package TUILayer;//makes this class a part of the TUILayer package
import java.util.*;
import ControlLayer.*;//The TUILayer needs to know the ControlLayer
import ModelLayer.*;
/**
 * 
 * User interface - main menu
 * The entry-point for the application:
 * Create an instance of class MainMenuUI and the constructor starts the application
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.02.24: Comments translated into English
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 *                    
 * (KBH): 2008.10.24: Change af manimenuStart to if
 */
public class MainMenuUI
{
    private static EmployeeUI empUI = new EmployeeUI();
    private static ItemUI itemUI = new ItemUI();
    private static CustomerUI customerUI = new CustomerUI();
    private static LeaseUI leaseUI = new LeaseUI();
    private static SaleUI saleUI = new SaleUI();
    
    public MainMenuUI()
    {
        
    }
    
    public void mainMenuStart()
    {
        boolean exit = false;
        while (!exit) //! means while exit not is true (that is: false)
        {
            int _choice = writeMainMenu();
            if(_choice == 1)
            {
                empUI.startMainMenu();
            }
            else{
                    if(_choice == 2)
                    {
                        customerUI.startMainMenu();
                    }
                    else
                    {
                        if(_choice == 3)
                        {
                            itemUI.startMainMenu();
                        }
                        else
                        {
                            if(_choice == 4)
                            {
                                saleUI.startMainMenu();
                            }
                            else
                            {
                                if(_choice == 5)
                                {
                                    leaseUI.startMainMenu();
                                }
                                else
                                {
                                    if(_choice == 6)
                                    {
                                        writeEnd();
                                        exit = true;
                                    }
                                }
                            }
                        }
                    }
             }
        }
    }
    
    private int writeMainMenu()
    {       
            // creates a keyboard object to read input
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** MAIN MENU ***");
            System.out.println(" (1) Employees");
            System.out.println(" (2) Customers");
            System.out.println(" (3) Items");
            System.out.println(" (4) Sale");
            System.out.println(" (5) Lease");
            System.out.println(" (6) Exit");
            System.out.print("\n Make your choice: ");
            
            int choice = keyboard.nextInt();
            
            return choice;
    }
    
    private void writeEnd()
    {
        System.out.println(" The System is shuting down ");
    }
    
 }
